home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / THXPlayLib / src / thxplay.asm < prev    next >
Encoding:
Assembly Source File  |  1998-06-17  |  5.1 KB  |  201 lines

  1. ;****** thxplay.library/--overview-- ******************************************
  2. ;
  3. ;   PURPOSE
  4. ;       To provide an interface to the THX2 player.
  5. ;
  6. ;   OVERVIEW
  7. ;       THX2  is  a  'chip' music tracker by Martin Wodok (Dexter/Abyss). It
  8. ;       comes with a rather cumbersome binary replayer, so you may play THX2
  9. ;       songs  in  your  own  programs.  This  provides an easy and powerful
  10. ;       interface to the THX2 player, providing a wide range of functions.
  11. ;
  12. ;        - Allocation: thxInit(), thxFree()
  13. ;        - Playing:    thxPlay(), thxStop(), thxPause(), thxWind()
  14. ;        - Volume:     thxGetVolume(), thxSetVolume()
  15. ;        - Multisong:  thxGetNumSongs(), thxSetSong()
  16. ;        - Sound FX:   thxPlayNote(), thxStopNote(), thxNoteFX()
  17. ;        - Misc:       thxSignalEnd(), thxSongEnded(), thxSyncByte(),
  18. ;                      thxPlaytime()
  19. ;
  20. ;       You  need to read a THX song in from disk or 'incbin' it. You should
  21. ;       load  it  into  PUBLIC  memory,  however it does not have to be CHIP
  22. ;       memory.
  23. ;
  24. ;       The  music  play  is,  as  you  would  expect, interrupt-driven, and
  25. ;       asynchronous. This interface automatically provides fallback support
  26. ;       for a VSYNC based replayer if it cannot allocate a CIA timer.
  27. ;
  28. ;       The  interface is 68000 compatible, optimised versions for the 68020
  29. ;       and better are also included. The interface is available as an Amiga
  30. ;       E module, a shared library, or a C link-library.
  31. ;
  32. ;   NOTE
  33. ;       This  interface was initially developed as an Amiga E module. With a
  34. ;       little  extra  effort,  it  is  also  available  as a runtime shared
  35. ;       library.  Therefore, it operates a simple mechanism in thxInit() and
  36. ;       thxFree()  to ensure only one task at any time is using the library.
  37. ;       See the notes of thxInit() for more information about this.
  38. ;
  39. ;       Also note that all examples are given in Amiga E code.
  40. ;
  41. ;       Synopsis is given as 3 lines: the assembler/register synopsis, the C
  42. ;       prototype,  and the E synopsis.
  43. ;
  44. ;   EXAMPLE
  45. ;       More thorough examples are included with the distribution.
  46. ;       This is an example in Amiga E, using the E module thx-play.m.
  47. ;
  48. ;       MODULE 'tools/thx-play', 'tools/file'
  49. ;       PROC main()
  50. ;         DEF mod
  51. ;         IF mod := loadfile(arg, 0, MEMF_PUBLIC)
  52. ;           IF thxInit(mod)=0
  53. ;             thxPlay()
  54. ;             REPEAT; WaitTOF(); UNTIL CtrlC() OR thxSongEnded()
  55. ;             thxStop()
  56. ;
  57. ;             thxFree()
  58. ;           ENDIF
  59. ;           freefile(mod)
  60. ;         ENDIF
  61. ;       ENDPROC
  62. ;
  63. ;       Here is the same example, but using the shared thxplay.library.
  64. ;       Note that Amiga E forces library functions to have capitalised
  65. ;       names, and that we must use OpenLibrary() and CloseLibrary().
  66. ;
  67. ;       MODULE 'thxplay', 'tools/file'
  68. ;       PROC main()
  69. ;         DEF mod
  70. ;         IF thxplaybase := OpenLibrary('thxplay.library', 5)
  71. ;           IF mod := loadfile(arg, 0, MEMF_PUBLIC)
  72. ;             IF ThxInit(mod) = 0
  73. ;               ThxPlay()
  74. ;               REPEAT; WaitTOF(); UNTIL CtrlC() OR ThxSongEnded()
  75. ;               ThxStop()
  76. ;
  77. ;               ThxFree()
  78. ;             ENDIF
  79. ;             freefile(mod)
  80. ;           ENDIF
  81. ;           CloseLibrary(thxplaybase)
  82. ;         ENDIF
  83. ;       ENDPROC
  84. ;
  85. ;
  86. ;****************************************************************************
  87. ;
  88. ;
  89.     incdir    include:
  90.     include    exec/execbase.i
  91.     include    exec/initializers.i
  92.     include    exec/libraries.i
  93.     include    exec/lists.i
  94.     include    exec/memory.i
  95.     include    exec/nodes.i
  96.     include    exec/resident.i
  97.     include    exec/semaphores.i
  98.     include    exec/types.i
  99.     include    hardware/intbits.i
  100.     include    lvo/exec_lib.i
  101.  
  102.     incdir    ""
  103.     ifd    LIBRARY
  104.     include    thxplay.library_rev.i
  105.     include    library.asm
  106.     endc
  107.  
  108.     include    misc.asm
  109.     include    note.asm
  110.     include    multisong.asm
  111.     include    volume.asm
  112.     include    song.asm
  113.     include    init.asm
  114.     include    interrupt.asm
  115.  
  116.     include    bin/thx-offsets.i
  117.     ifd    USE020
  118. THX    incbin    bin/thx-replayer020.bin
  119.     else
  120. THX    incbin    bin/thx-replayer000.bin
  121.     endc
  122.  
  123.     ifd    ENAMES
  124.     xdef    thxInit__i
  125.     xdef    thxFree
  126. thxInit__i=thxInit
  127.  
  128.     xdef    thxPlaytime
  129.     xdef    thxSyncByte
  130.     xdef    thxSignalEnd__ii
  131. thxSignalEnd__ii=thxSignalEnd
  132.  
  133.     xdef    thxGetNumSongs
  134.     xdef    thxSetSong__i
  135. thxSetSong__i=thxSetSong
  136.  
  137.     xdef    thxPlayNote__iii
  138.     xdef    thxNoteFX__iii
  139.     xdef    thxStopNote__i
  140. thxPlayNote__iii=thxPlayNote
  141. thxNoteFX__iii=thxNoteFX
  142. thxStopNote__i=thxStopNote
  143.  
  144.     xdef    thxPlay
  145.     xdef    thxPause
  146.     xdef    thxStop
  147.     xdef    thxWind__i
  148. thxWind__i=thxWind
  149.  
  150.     xdef    thxGetVolume
  151.     xdef    thxSetVolume__i
  152. thxSetVolume__i=thxSetVolume
  153.     endc
  154.  
  155.  
  156.     ifd    CNAMES
  157.     xdef    _thxInit
  158.     xdef    _thxFree
  159.  
  160.     xdef    _thxPlaytime
  161.     xdef    _thxSyncByte
  162.     xdef    _thxSignalEnd
  163.  
  164.     xdef    _thxGetNumSongs
  165.     xdef    _thxSetSong
  166.  
  167.     xdef    _thxPlayNote
  168.     xdef    _thxNoteFX
  169.     xdef    _thxStopNote
  170.  
  171.     xdef    _thxPlay
  172.     xdef    _thxPause
  173.     xdef    _thxStop
  174.     xdef    _thxWind
  175.  
  176.     xdef    _thxGetVolume
  177.     xdef    _thxSetVolume
  178.  
  179. _thxInit=thxInit
  180. _thxFree=thxFree
  181.  
  182. _thxPlaytime=thxPlaytime
  183. _thxSyncByte=thxSyncByte
  184. _thxSignalEnd=thxSignalEnd
  185.  
  186. _thxGetNumSongs=thxGetNumSongs
  187. _thxSetSong=thxSetSong
  188.  
  189. _thxPlayNote=thxPlayNote
  190. _thxNoteFX=thxNoteFX
  191. _thxStopNote=thxStopNote
  192.  
  193. _thxPlay=thxPlay
  194. _thxPause=thxPause
  195. _thxStop=thxStop
  196. _thxWind=thxWind
  197.  
  198. _thxGetVolume=thxGetVolume
  199. _thxSetVolume=thxSetVolume
  200.     endc
  201.